FROM ubuntu:xenial

MAINTAINER atompi <atompi@foxmail.com>

# init
WORKDIR /usr/local/src
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN dpkg-reconfigure -f noninteractive tzdata
COPY sources.list /etc/apt/sources.list
RUN echo "nameserver 114.114.114.114" >> /etc/resolv.conf
RUN apt-get update

# install logstash
COPY logstash-2.4.1_all.deb /usr/local/src
RUN dpkg -i logstash-2.4.1_all.deb

# install redis
COPY redis-3.2.8.tar.gz /usr/local/src/
RUN tar -zxf redis-3.2.8.tar.gz
WORKDIR /usr/local/src/redis-3.2.8
RUN make && make install
RUN cd utils && (echo;echo;echo;echo;echo;echo)|./install_server.sh
RUN sed -i 's/127.0.0.1/0.0.0.0/g' /etc/redis/6379.conf

# config logstash indexer (get nginx access log)
RUN mkdir -p /opt/logstash/patterns
RUN cp logstash-2.4.1/nginx /opt/logstash/patterns/
RUN cp logstash-2.4.1/nginx_access_indexer.conf /etc/logstash/conf.d/

# config logstash shipper (get nginx access log)
#RUN cp logstash-2.4.1/nginx_access_shipper.conf /etc/logstash/conf.d/

RUN service logstash start
CMD ["tail","-f","/var/log/logstash/logstash.log"]

EXPOSE 6379
